package com.jadeen.controller.serverController;


import com.jadeen.common.controller.BaseController;
import com.jadeen.common.domain.AjaxResult;
import com.jadeen.common.page.TableDataInfo;
import com.jadeen.entity.domain.Resource;
import com.jadeen.service.IResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资源Controller
 * 
 * @author jadeen
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/share/resource")
public class ResourceController extends BaseController
{
    @Autowired
    private IResourceService resourceService;

    /**
     * 查询资源列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Resource resource)
    {
        startPage();
        List<Resource> list = resourceService.selectResourceList(resource);
        return getDataTable(list);
    }


    /**
     * 获取资源详细信息
     */
    @GetMapping(value = "/{resourceId}")
    public AjaxResult getInfo(@PathVariable("resourceId") Long resourceId)
    {
        return success(resourceService.selectResourceByResourceId(resourceId));
    }

    /**
     * 新增资源
     */
    @PostMapping
    public AjaxResult add(@RequestBody Resource resource)
    {
        return toAjax(resourceService.insertResource(resource));
    }

    /**
     * 修改资源
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Resource resource)
    {
        return toAjax(resourceService.updateResource(resource));
    }

    /**
     * 删除资源
     */
	@DeleteMapping("/{resourceIds}")
    public AjaxResult remove(@PathVariable Long[] resourceIds)
    {
        return toAjax(resourceService.deleteResourceByResourceIds(resourceIds));
    }
}
